package com.situ.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.web.entity.PageBean;
import com.situ.web.service.IStudentService;
import com.situ.web.service.impl.StudentServiceImpl;

public class PageServlet extends HttpServlet{
	private IStudentService studentService = new StudentServiceImpl();
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		int pageNo = 1;
		int pageSize = 3;
		if (req.getParameter("pageNo") != null){
			pageNo = Integer.parseInt(req.getParameter("pageNo"));
		}
		if (req.getParameter("pageSize") != null){
			pageSize = Integer.parseInt(req.getParameter("pageSize"));
		}
		System.out.println("pageNo:" + pageNo);
		System.out.println("pageSize" + pageSize);
		PageBean pageBean = studentService.findPageBean(pageNo,pageSize);
		req.setAttribute("pageBean", pageBean);
		req.getRequestDispatcher("/student_page_list.jsp").forward(req, resp);
	}
}
